package com.sneakxy.mybase4j.platform.controller;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.csource.common.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sneakxy.mybase4j.base.controller.BaseController;
import com.sneakxy.mybase4j.platform.beans.UEditor;
import com.sneakxy.mybase4j.platform.service.IUEditorService;

@Controller
@RequestMapping("/editor/ueditor/")
public class UEditorFileController extends BaseController {

	@Resource
	private IUEditorService uEditorService;
	
	@RequestMapping("image/{id}")
	public void image(HttpServletResponse response, @PathVariable String id) throws IOException, MyException {
		this.uEditorService.download(response, id, UEditor.TYPE_IMAGE);
	}
	
	@RequestMapping("video/{id}")
	public void video(HttpServletResponse response, @PathVariable String id) throws IOException, MyException {
		this.uEditorService.download(response, id, UEditor.TYPE_VIDEO);
	}
	
	@RequestMapping("file/{id}")
	public void file(HttpServletResponse response, @PathVariable String id) throws IOException, MyException {
		this.uEditorService.download(response, id, UEditor.TYPE_FILE);
	}
	
}
